package cn.huiyunche.base.service.interfaces.impl;

import cn.huiyunche.base.service.enums.DWaybillFeeEnum;
import cn.huiyunche.base.service.interfaces.*;
import cn.huiyunche.base.service.mappers.*;
import cn.huiyunche.base.service.model.*;
import cn.huiyunche.base.service.vo.ScBaseCvTankvolumeVo;
import cn.huiyunche.tools.basic.exceptions.BusinessException;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @FileName: cn.huiyunche.base.service.interfaces.impl
 * @Description: Description
 * @author: Aaron
 * @date: 2017/3/2 下午6:09
 */
@Service
public class DWaybillFeeServiceImpl implements DWaybillFeeService {

    private static final Logger LOGGER = LoggerFactory.getLogger(DWaybillFeeServiceImpl.class);

    @Autowired
    private ScPriceconfOcService scPriceconfOcService;

    @Autowired
    private DRouteVehiclePriceEffectiveMapper dRouteVehiclePriceEffectiveMapper;

    @Autowired
    private DVehiclePreKilometerFeeEffectiveMapper dVehiclePreKilometerFeeEffectiveMapper;

    @Autowired
    private DRouteMapper dRouteMapper;

    @Autowired
    private DFuelTypeMapper dFuelTypeMapper;

    @Autowired
    private DFuelPriceEffectiveMapper dFuelPriceEffectiveMapper;

    @Autowired
    private ScPriceconfFreightService scPriceconfFreightService;

    @Autowired
    private ScPriceconfMileService scPriceconfMileService;

    @Autowired
    private DVehicleClassifyService dVehicleClassifyService;

    @Autowired
    private  ScBaseCvTankvolumeService scBaseCvTankvolumeService;

//    @Override
//    public Map<Integer, Object> getWaybillCostByCalc(Integer vehicleClassifyId, BigDecimal firstFuelTotal, String oProvince, String oTag, String dProvice, String dTag) throws Exception {
//        LOGGER.info("DWaybillFeeServiceImpl.handleWaybillCost params : {}, {}, {}, {}, {}", vehicleClassifyId, oProvince, oTag, dProvice, dTag);
//
//        if (null == vehicleClassifyId && 0 == vehicleClassifyId.intValue()) {
//            LOGGER.error("DWaybillFeeServiceImpl.handleWaybillCost param vehicleClassifyId must not be null");
//            throw new IllegalArgumentException("车型分类编码不能为空");
//        }
//
//        if (null == firstFuelTotal) {
//            LOGGER.error("DWaybillFeeServiceImpl.handleWaybillCost param firstFuelTotal must not be null");
//            throw new IllegalArgumentException("第一桶油量不能为空");
//        }
//
//        if (StringUtils.isBlank(oProvince)) {
//            LOGGER.error("DWaybillFeeServiceImpl.handleWaybillCost param oProvince must not be null");
//            throw new IllegalArgumentException("起始地省份不能为空");
//        }
//
//        if (StringUtils.isBlank(oTag)) {
//            LOGGER.error("DWaybillFeeServiceImpl.handleWaybillCost param oTag must not be null");
//            throw new IllegalArgumentException("起始地城市不能为空");
//        }
//
//        if (StringUtils.isBlank(dProvice)) {
//            LOGGER.error("DWaybillFeeServiceImpl.handleWaybillCost param dProvice must not be null");
//            throw new IllegalArgumentException("目的地省份不能为空");
//        }
//
//        if (StringUtils.isBlank(dTag)) {
//            LOGGER.error("DWaybillFeeServiceImpl.handleWaybillCost param dTag must not be null");
//            throw new IllegalArgumentException("目的地城市不能为空");
//        }
//
//        /**
//         * 查询车型分类
//         */
//        DVehicleClassify dVehicleClassify = dVehicleClassifyService.selectByVehicleClassifyId(vehicleClassifyId);
//        if (null == dVehicleClassify) {
//            LOGGER.error("DWaybillFeeServiceImpl.handleWaybillCost dVehicleClassifies dVehicleClassify must not be null");
//            throw new BusinessException("车型分类不能为空");
//        }
//
//        /**
//         * 查询车型油耗
//         */
//        ScPriceconfOc scPriceconfOc = scPriceconfOcService.selectEffective(dVehicleClassify.getId(), new Date());
//        if ( null == scPriceconfOc ) {
//            LOGGER.error("DWaybillFeeServiceImpl.handleWaybillCost scPriceconfOcs must not be null");
//            throw new BusinessException("车型油耗不能为空");
//        }
//
//        /**
//         * 匹配线路
//         */
//        DRoute route = this.matchRoute(oProvince, oTag, dProvice, dTag);
//        if (null == route) {
//            LOGGER.info("DWaybillFeeServiceImpl.handleWaybillCost has no match route");
//            throw new BusinessException("没有匹配的线路");
//        }
//
//        /**
//         * 查询线路生效每公里劳务价
//         */
//        ScPriceconfFreight scPriceconfFreight = scPriceconfFreightService.selectEffectiveFreight(route.getId(), new Date());
//        if (null == scPriceconfFreight) {
//            LOGGER.error("DWaybillFeeServiceImpl.handleWaybillCost dVehicleClassifies error matchRoute is null");
//            throw new BusinessException("线路价格变更不能为空");
//        }
//
//        /**
//         * 查询线路生效里程
//         */
//        ScPriceconfMile scPriceconfMile = scPriceconfMileService.selectByEffectiveDateAndRouteId(route.getId(), new Date());
//        if (null == scPriceconfMile) {
//            LOGGER.error("DWaybillFeeServiceImpl.handleWaybillCost dVehicleClassifies scPriceconfMile must not be null");
//            throw new BusinessException("线路里程变更不能为空");
//        }
//
//        //查询市场油价
//        DFuelPriceEffective fuelPriceEffective = this.selectCurrentOilPrice(dVehicleClassify.getFuelTypeId());
//        if (null == fuelPriceEffective) {
//            LOGGER.error("DWaybillFeeServiceImpl.handleWaybillCost fuelPriceEffective must not be null");
//            throw new BusinessException("当前市场价不能为空");
//        }
//
//        //里程
//        BigDecimal distance = scPriceconfMile.getCurrentValue();
//
//        //劳务费单价
//        BigDecimal laborCosts = scPriceconfFreight.getCurrentValue();
//
//        //总劳务费 = 劳务费单价 * 里程
//        BigDecimal totalLaborCosts = laborCosts.multiply(distance).setScale(2, RoundingMode.HALF_UP);
//
//        //单公里油价
//        BigDecimal priceOilPerKm = scPriceconfOc.getCurrentValue().divide(BigDecimal.valueOf(100)).multiply(fuelPriceEffective.getMarketPrice()).setScale(2, RoundingMode.HALF_UP);
//
//        //总油费 = 车型每公里油费 /100 * 油价 * 里程
//        BigDecimal totalOilFee = scPriceconfOc.getCurrentValue().divide(BigDecimal.valueOf(100)).multiply(fuelPriceEffective.getMarketPrice()).multiply(distance).setScale(2, RoundingMode.HALF_UP);
//
//        //第一桶油费 = 市场价 * 第一桶油量
//        BigDecimal firstBucketFee = firstFuelTotal.multiply(fuelPriceEffective.getMarketPrice()).setScale(2, RoundingMode.HALF_UP);
//
//        //剩余油费（充值油费） = 总油费 - 第一桶油费
//        BigDecimal remainingOilFee = totalOilFee.subtract(firstBucketFee);
//
//        //总运价 =  总劳务费 + 总油费；
//        BigDecimal totalFreight = totalLaborCosts.add(totalOilFee).setScale(2);
//
//        Map<Integer, Object> fees = new HashedMap();
//        fees.put(DWaybillFeeEnum.LABOR_COSTS.getValue(), totalLaborCosts);//运费(服务费)
//        fees.put(DWaybillFeeEnum.REMAINING_OIL_FEE.getValue(), remainingOilFee);//油卡充值金额
//        fees.put(DWaybillFeeEnum.MARKET_OIL_PRICE.getValue(), fuelPriceEffective.getMarketPrice());//油价
//        fees.put(DWaybillFeeEnum.TOTAL_OIL_COST.getValue(), totalOilFee);//总油费
//        fees.put(DWaybillFeeEnum.TOTAL_SHIPPING_COST.getValue(), totalFreight);//总运费
//        fees.put(DWaybillFeeEnum.SHIP_DISTANCE.getValue(), distance);//公里数   =1 后加
//        fees.put(DWaybillFeeEnum.PRICE_PER_KM.getValue(), laborCosts);//单公里运价   =2 后加
//        fees.put(DWaybillFeeEnum.FIRST_BUCKET_OIL_FEE.getValue(), firstBucketFee);//第一桶油费 = 3 后加
//        fees.put(DWaybillFeeEnum.PRICE_OIL_PER_KM.getValue(), priceOilPerKm);//单公里油价 = 4 后加
//
//        return fees;
//    }

    @Override
    public DRouteVehiclePriceEffective matchVehicleRoute(Integer vehicleTypeId, Integer routeId) throws Exception {
        LOGGER.info("DWaybillFeeServiceImpl.matchVehicleRoute params : {}, {}", vehicleTypeId, routeId);

        if (null == vehicleTypeId && 0 == vehicleTypeId.intValue()) {
            LOGGER.error("DWaybillFeeServiceImpl.matchVehicleRoute param vehicleClassifyId must not be null");
            throw new IllegalArgumentException("车型分类编码不能为空");
        }

        DRouteVehiclePriceEffectiveExample example = new DRouteVehiclePriceEffectiveExample();
        example.createCriteria().andVehicleTypeIdEqualTo(vehicleTypeId).andRouteIdEqualTo(routeId)
                .andEffectiveDateLessThanOrEqualTo(new Date()).andInvalidDateGreaterThan(new Date());

        List<DRouteVehiclePriceEffective> dRouteVehiclePriceEffectives = dRouteVehiclePriceEffectiveMapper.selectByExample(example);

        if (CollectionUtils.isEmpty(dRouteVehiclePriceEffectives)) {

            DRouteVehiclePriceEffectiveExample example1 = new DRouteVehiclePriceEffectiveExample();
            example1.createCriteria().andVehicleTypeIdEqualTo(vehicleTypeId).andRouteIdEqualTo(routeId)
                    .andEffectiveDateLessThanOrEqualTo(new Date()).andInvalidDateIsNull();
            dRouteVehiclePriceEffectives = dRouteVehiclePriceEffectiveMapper.selectByExample(example1);

            if (CollectionUtils.isEmpty(dRouteVehiclePriceEffectives)) {
                LOGGER.error("DWaybillFeeServiceImpl.matchVehicleRoute error no match line");
                throw new BusinessException("没有匹配的车型线路");
            } else {
                return dRouteVehiclePriceEffectives.get(0);
            }
        } else {
            return dRouteVehiclePriceEffectives.get(0);
        }
    }

    @Override
    public DRoute matchRoute(String oProvince, String oTag, String dProvice, String dTag) throws Exception {
        LOGGER.info("DWaybillFeeServiceImpl.matchRoute param : {}, {}, {}, {}", oProvince, oTag, dProvice, dTag);

        if (StringUtils.isBlank(oProvince)) {
            LOGGER.error("DWaybillFeeServiceImpl.matchRoute param oProvince must not be null");
            throw new IllegalArgumentException("起始地省份不能为空");
        }

        if (StringUtils.isBlank(oTag)) {
            LOGGER.error("DWaybillFeeServiceImpl.matchRoute param oTag must not be null");
            throw new IllegalArgumentException("起始地城市不能为空");
        }

        if (StringUtils.isBlank(dProvice)) {
            LOGGER.error("DWaybillFeeServiceImpl.matchRoute param dProvice must not be null");
            throw new IllegalArgumentException("目的地省份不能为空");
        }

        if (StringUtils.isBlank(dTag)) {
            LOGGER.error("DWaybillFeeServiceImpl.matchRoute param dTag must not be null");
            throw new IllegalArgumentException("目的地城市不能为空");
        }

        DRouteExample routeExample = new DRouteExample();
        routeExample.createCriteria().andEnableEqualTo(true)
                .andOProvinceLikeInsensitive("%" + oProvince + "%")
                .andOTagLikeInsensitive("%" + oTag + "%")
                .andDProvinceLikeInsensitive("%" + dProvice + "%")
                .andDTagLikeInsensitive("%" + dTag + "%");
        List<DRoute> routes = dRouteMapper.selectByExample(routeExample);
        if (CollectionUtils.isEmpty(routes)) {
            LOGGER.info("DWaybillFeeServiceImpl.matchVehicleRoute error no line ");
            throw new BusinessException("没有匹配的线路");
        }

        return routes.get(0);
    }

    @Override
    public DVehiclePreKilometerFeeEffective selectVehiclePreKilometerFeeByVhielceTypeId(Integer vehicleTypeId) throws Exception {
        LOGGER.info("DWaybillFeeServiceImpl.selectVehiclePreKilometerFeeByVhielceTypeId param : {}", vehicleTypeId);

        if (null == vehicleTypeId || 0 == vehicleTypeId.intValue()) {
            LOGGER.error("DWaybillFeeServiceImpl.selectVehiclePreKilometerFeeByVhielceTypeId param vehicleClassifyId must not be null");
            throw new IllegalArgumentException("车型分类编码不能为空");
        }

        DVehiclePreKilometerFeeEffectiveExample example = new DVehiclePreKilometerFeeEffectiveExample();
        example.createCriteria().andVehicleTypeIdEqualTo(vehicleTypeId).andEffectiveDateLessThanOrEqualTo(new Date())
                .andInvalidDateGreaterThan(new Date());
        List<DVehiclePreKilometerFeeEffective> feeEffectives = dVehiclePreKilometerFeeEffectiveMapper.selectByExample(example);

        if (CollectionUtils.isEmpty(feeEffectives)) {

            DVehiclePreKilometerFeeEffectiveExample example1 = new DVehiclePreKilometerFeeEffectiveExample();
            example1.createCriteria().andVehicleTypeIdEqualTo(vehicleTypeId).andEffectiveDateLessThanOrEqualTo(new Date())
                    .andInvalidDateIsNull();
            feeEffectives = dVehiclePreKilometerFeeEffectiveMapper.selectByExample(example1);

            if (CollectionUtils.isEmpty(feeEffectives)) {
                LOGGER.error("DWaybillFeeServiceImpl.selectVehiclePreKilometerFeeByVhielceTypeId error feeEffectives is empty");
                throw new BusinessException("车型每公里油费变动不能为空");
            } else {
                return feeEffectives.get(0);
            }
        } else {
            return feeEffectives.get(0);
        }

    }

    @Override
    public DFuelPriceEffective selectCurrentOilPrice(Integer fuelTypeId) {
        LOGGER.info("DWaybillFeeServiceImpl.selectCurrentOilPrice param : {}", fuelTypeId);

        if (null == fuelTypeId) {
            LOGGER.error("DWaybillFeeServiceImpl.selectCurrentOilPrice param fuelTypeId must not be null");
            throw new IllegalArgumentException("燃油类型主键不能为空");
        }

        DFuelPriceEffectiveExample example = new DFuelPriceEffectiveExample();
        example.createCriteria().andFuelTypeIdEqualTo(fuelTypeId)
                .andEffectiveDateLessThanOrEqualTo(new Date())
                .andInvalidDateIsNull();
        List<DFuelPriceEffective> list = dFuelPriceEffectiveMapper.selectByExample(example);

        if (CollectionUtils.isEmpty(list)) {

            DFuelPriceEffectiveExample example1 = new DFuelPriceEffectiveExample();
            example1.createCriteria().andFuelTypeIdEqualTo(fuelTypeId)
                    .andEffectiveDateLessThanOrEqualTo(new Date())
                    .andInvalidDateGreaterThan(new Date());

            list = dFuelPriceEffectiveMapper.selectByExample(example1);

            if (CollectionUtils.isEmpty(list)) {
                LOGGER.error("DWaybillFeeServiceImpl.selectVehiclePreKilometerFeeByVhielceTypeId error feeEffectives is empty");
                throw new BusinessException("燃油价格变动不能为空");
            } else {
                return list.get(0);
            }
        } else {
            return list.get(0);
        }

    }

    @Override
    public Map<Integer, Object>  getWaybillCostByCalc(Integer vehicleClassifyId, String oProvince, String oTag, String dProvice, String dTag, BigDecimal extraCost) throws Exception{
        LOGGER.info("DWaybillFeeServiceImpl.getWaybillFirstBucketOilByCalc params : {}, {}, {}, {}, {}, {}", vehicleClassifyId, oProvince, oTag, dProvice, dTag, extraCost);

        if (null == vehicleClassifyId && 0 == vehicleClassifyId.intValue()) {
            LOGGER.error("DWaybillFeeServiceImpl.getWaybillFirstBucketOil param vehicleClassifyId must not be null");
            throw new IllegalArgumentException("车型分类编码不能为空");
        }

        if (StringUtils.isBlank(oProvince)) {
            LOGGER.error("DWaybillFeeServiceImpl.getWaybillFirstBucketOil param oProvince must not be null");
            throw new IllegalArgumentException("起始地省份不能为空");
        }

        if (StringUtils.isBlank(oTag)) {
            LOGGER.error("DWaybillFeeServiceImpl.getWaybillFirstBucketOil param oTag must not be null");
            throw new IllegalArgumentException("起始地城市不能为空");
        }

        if (StringUtils.isBlank(dProvice)) {
            LOGGER.error("DWaybillFeeServiceImpl.getWaybillFirstBucketOil param dProvice must not be null");
            throw new IllegalArgumentException("目的地省份不能为空");
        }

        if (StringUtils.isBlank(dTag)) {
            LOGGER.error("DWaybillFeeServiceImpl.getWaybillFirstBucketOil param dTag must not be null");
            throw new IllegalArgumentException("目的地城市不能为空");
        }

        /**
         * 查询车型分类
         */
        DVehicleClassify dVehicleClassify = dVehicleClassifyService.selectByVehicleClassifyId(vehicleClassifyId);
        if (null == dVehicleClassify) {
            LOGGER.error("DWaybillFeeServiceImpl.getWaybillFirstBucketOil dVehicleClassifies dVehicleClassify must not be null");
            throw new BusinessException("车型分类不能为空");
        }

        /**
         * 查询油箱容积
         */
        ScBaseCvTankvolumeVo scBaseCvTankvolume=scBaseCvTankvolumeService.selectCvTankvolumeByCvTypeId(vehicleClassifyId);
        if(null == scBaseCvTankvolume){
            LOGGER.error("DWaybillFeeServiceImpl.getWaybillFirstBucketOil scBaseCvTankvolume must not be null");
            throw new BusinessException("油箱容积不能为空");
        }

        /**
         * 查询车型油耗
         */
        ScPriceconfOc scPriceconfOc = scPriceconfOcService.selectEffective(dVehicleClassify.getId(), new Date());
        if ( null == scPriceconfOc ) {
            LOGGER.error("DWaybillFeeServiceImpl.getWaybillFirstBucketOil scPriceconfOcs must not be null");
            throw new BusinessException("车型油耗不能为空");
        }

        /**
         * 匹配线路
         */
        DRoute route = this.matchRoute(oProvince, oTag, dProvice, dTag);
        if (null == route) {
            LOGGER.info("DWaybillFeeServiceImpl.getWaybillFirstBucketOil has no match route");
            throw new BusinessException("没有匹配的线路");
        }

        /**
         * 查询线路生效里程
         */
        ScPriceconfMile scPriceconfMile = scPriceconfMileService.selectByEffectiveDateAndRouteId(route.getId(), new Date());
        if (null == scPriceconfMile) {
            LOGGER.error("DWaybillFeeServiceImpl.getWaybillFirstBucketOil dVehicleClassifies scPriceconfMile must not be null");
            throw new BusinessException("线路里程变更不能为空");
        }
        /**
         * 查询线路生效每公里劳务价
         */
        ScPriceconfFreight scPriceconfFreight = scPriceconfFreightService.selectEffectiveFreight(route.getId(), new Date());
        if (null == scPriceconfFreight) {
            LOGGER.error("DWaybillFeeServiceImpl.handleWaybillCost dVehicleClassifies error matchRoute is null");
            throw new BusinessException("线路价格变更不能为空");
        }

        //查询市场油价
        DFuelPriceEffective fuelPriceEffective = this.selectCurrentOilPrice(dVehicleClassify.getFuelTypeId());
        if (null == fuelPriceEffective) {
            LOGGER.error("DWaybillFeeServiceImpl.handleWaybillCost fuelPriceEffective must not be null");
            throw new BusinessException("当前市场价不能为空");
        }

        Integer fuelTypeId = dVehicleClassify.getFuelTypeId(); // 油品id
        DFuelType dFuelType = dFuelTypeMapper.selectByPrimaryKey(fuelTypeId);
        String fuleName = dFuelType.getFuelName(); // 油品

        //里程
        BigDecimal distance = scPriceconfMile.getCurrentValue();

        //油箱容积
        BigDecimal tankVolume = scBaseCvTankvolume.getTankVolume();

        //车型油耗
        BigDecimal currentValue = scPriceconfOc.getCurrentValue();

        //劳务费单价
        BigDecimal laborCosts = scPriceconfFreight.getCurrentValue();


        //单趟所需油量y
        BigDecimal totalOil = currentValue.multiply(distance).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP);

        //油箱最高加油量z
        BigDecimal maxOil = tankVolume.multiply(BigDecimal.valueOf(0.85)).setScale(2, RoundingMode.HALF_UP);

        //第一箱油量
        BigDecimal firstBucketOil = null;

        //剩余油量
        BigDecimal remainOil = null;

        //单趟所需油量>=油箱最高加油量,第一箱油为油箱最高加油量z,剩余油量为单趟所需油量-油箱最高加油量 x-z
        if(totalOil.intValue() >= maxOil.intValue()){
            firstBucketOil = maxOil;
            remainOil = totalOil.subtract(maxOil);
        }
        //单趟所需油量<油箱最高加油量,第一箱油为单趟所需油量y,油箱剩余油量为x-y即为0
        if(totalOil.intValue()<maxOil.intValue()){
            firstBucketOil = totalOil;
            remainOil = totalOil.subtract(totalOil);
        }

        //单公里油价
        BigDecimal priceOilPerKm = scPriceconfOc.getCurrentValue().divide(BigDecimal.valueOf(100)).multiply(fuelPriceEffective.getMarketPrice()).setScale(2, RoundingMode.HALF_UP);

        //总劳务费 = 劳务费单价 * 里程
        BigDecimal totalLaborCosts = laborCosts.multiply(distance).setScale(2, RoundingMode.HALF_UP);

        //总油费 = 车型每公里油费 /100 * 油价 * 里程
        BigDecimal totalOilFee = scPriceconfOc.getCurrentValue().divide(BigDecimal.valueOf(100)).multiply(fuelPriceEffective.getMarketPrice()).multiply(distance).setScale(2, RoundingMode.HALF_UP);

        //总油量
        BigDecimal totalFuelConsumption = scPriceconfOc.getCurrentValue().divide(BigDecimal.valueOf(100)).multiply(distance).setScale(2, RoundingMode.HALF_UP);

        //第一桶油费 = 市场价 * 第一桶油量
//        BigDecimal firstBucketFee = firstBucketOil.multiply(fuelPriceEffective.getMarketPrice()).setScale(2, RoundingMode.HALF_UP);
        BigDecimal firstBucketFee = remainOil.compareTo(new BigDecimal("0.00")) == 0 ? totalOilFee : firstBucketOil.multiply(fuelPriceEffective.getMarketPrice()).setScale(2, RoundingMode.HALF_UP);
        		
        //剩余油费（充值油费） = 总油费 - 第一桶油费
        BigDecimal remainingOilFee = totalOilFee.subtract(firstBucketFee);

        //总运价 =  总劳务费 + 总油费 + 附加费；
        if ( null == extraCost) {
        	extraCost = new BigDecimal(0);
        }
        BigDecimal totalFreight = totalLaborCosts.add(totalOilFee).add(extraCost).setScale(2);

        Map<Integer, Object> fees = new HashedMap();
        fees.put(DWaybillFeeEnum.LABOR_COSTS.getValue(), totalLaborCosts);//运费(服务费)
        fees.put(DWaybillFeeEnum.REMAINING_OIL_FEE.getValue(), remainingOilFee);//油卡充值金额
        fees.put(DWaybillFeeEnum.MARKET_OIL_PRICE.getValue(), fuelPriceEffective.getMarketPrice());//油价
        fees.put(DWaybillFeeEnum.TOTAL_OIL_COST.getValue(), totalOilFee);//总油费
        fees.put(DWaybillFeeEnum.TOTAL_SHIPPING_COST.getValue(), totalFreight);//总运费
        fees.put(DWaybillFeeEnum.SHIP_DISTANCE.getValue(), distance);//公里数   =1 后加
        fees.put(DWaybillFeeEnum.PRICE_PER_KM.getValue(), laborCosts);//单公里运价   =2 后加
        fees.put(DWaybillFeeEnum.FIRST_BUCKET_OIL_FEE.getValue(), firstBucketFee);//第一桶油费 = 3 后加
        fees.put(DWaybillFeeEnum.PRICE_OIL_PER_KM.getValue(), priceOilPerKm);//单公里油价 = 4 后加
        fees.put(DWaybillFeeEnum.FIRST_BUCKET_OIL.getValue(), firstBucketOil);//第一桶油量 = 5 2017-06-06 11:22:55  ligl
        fees.put(DWaybillFeeEnum.OIL_CONSUMPTION.getValue(), currentValue);//车型油耗 = 6 2017-06-06 11:22:55  ligl
        fees.put(DWaybillFeeEnum.REMAIN_OIL.getValue(), remainOil);//剩余油量 = 7 2017-06-06 11:22:55  ligl
        fees.put(DWaybillFeeEnum.TANKVOLUME.getValue(), tankVolume);//车型容积 = 8 2017-06-06 11:22:55  ligl
        fees.put(DWaybillFeeEnum.FUEL_TYPE.getValue(), fuleName);//油品 = 9 2017-06-06 11:22:55  ligl
        fees.put(DWaybillFeeEnum.TOTAL_FUEL_CONSUMPTION.getValue(), totalFuelConsumption);//总油量 = 10 2017-07-05 17:45:50  ligl

        return fees;

           /* 判断条件	第一箱油量	剩余油量
            Y≥Z         	Z	        X-Z
            Y<Z         	Y	        X-Y
            备注：
            X:单趟所需油量=油耗*加油里程/100
            Y:单趟所需油量
            Z:油箱最高加油量=油箱容积*0.85
            注：原来计算方式种，Y=X*0.85，修改后X与Y相等，即X=Y
            */
    }
}
